import os
import numpy as np
from tensorflow import keras
from tensorflow.keras.preprocessing import image

train_images = []
train_target = []
test_images = []
test_target = []

default_dir = os.getcwd()
train_dir = default_dir + '/../data/archive/training_set/'
test_dir = default_dir + '/../data/archive/test_set/'
print(default_dir)
print(train_dir)


def get_data(data_dir):
    # get data's on training cat
    train_list = []
    train_data_list = os.listdir(data_dir)
    for i in range(len(train_data_list)):
        current_dir = data_dir + train_data_list[0]
        train_data = os.listdir(current_dir)
        for i in range(len(train_data)):
            train_data_set_list = current_dir + '/' + train_data[i]
            if train_data_set_list.split('.')[-1] == 'jpg':
                train_list.append(train_data_set_list)
    return train_list


get_data(train_dir)

# print('Number of cats in our train data is: ', len(train_cat))
#
#
# for i in train_cat:
#     try:
#         directory = train_dir + '/cats/' + i
#         img = image.load_img(directory, target_size=(224, 224), grayscale=False)
#         img = image.img_to_array(img)
#         img = img / 255
#         train_images.append(img)
#         os.chdir(default_dir)
#         train_target.append(0)
#     except OSError as err:
#         continue
# train_images = np.array(train_images)
# default_dir = os.getcwd()
